package com.ccs.testdatas;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;

public class Nursing {
	
	public void discharge(WebDriver driver, String pin, String option){
		
		driver.findElement(By.xpath("//input[@id='criteria']")).sendKeys(pin);
		driver.findElement(By.xpath("//input[@name='search']")).click();
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		
		if(option=="special"){
			Select action = new Select(driver.findElement(By.xpath("//table[@id='occupancyList']/tbody/tr/td[9]/select")));	
			action.selectByVisibleText("Discharge Instructions ");
			driver.findElement(By.xpath("//table[@id='occupancyList']/tbody/tr/td[10]/input")).click();
			driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		}else{
			Select action = new Select(driver.findElement(By.xpath("//table[@id='occupancyList']/tbody/tr/td[6]/select")));
			action.selectByVisibleText("Discharge Instructions ");
			driver.findElement(By.xpath("//table[@id='occupancyList']/tbody/tr/td[7]/input")).click();
			driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		}
		
		driver.findElement(By.xpath("//input[@id='txtFinalDiagnosis']")).sendKeys("Frequent Fever");
		driver.findElement(By.xpath("//input[@value='Add']")).click();
		Select disposition = new Select(driver.findElement(By.xpath("//select[@id='diagnosisForm.disposition']")));
		disposition.selectByVisibleText("RECOVERED");		
		
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		driver.findElement(By.xpath("//input[@id='btnSave']")).click();
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		
		System.out.println("Discharge Instructions Completed.");
		
		
	}
	
	public void pf(WebDriver driver, String pin, String option){

		driver.findElement(By.xpath("//input[@id='criteria']")).sendKeys(pin);
		driver.findElement(By.xpath("//input[@name='search']")).click();
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		
		if(option=="special"){
			Select action = new Select(driver.findElement(By.xpath("//table[@id='occupancyList']/tbody/tr/td[9]/select")));
			action.selectByVisibleText("Doctor and PF Amount");
			driver.findElement(By.xpath("//table[@id='occupancyList']/tbody/tr/td[10]/input")).click();
			driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		}
		else{
			Select action = new Select(driver.findElement(By.xpath("//table[@id='occupancyList']/tbody/tr/td[6]/select")));
			action.selectByVisibleText("Doctor and PF Amount");
			driver.findElement(By.xpath("//table[@id='occupancyList']/tbody/tr/td[7]/input")).click();
			driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		}
		
		driver.findElement(By.xpath("//tbody[@id='admissionDoctorBeanRows']/tr/td[6]/input[2]")).click();
		driver.findElement(By.xpath("//input[@id='btnAddPf']")).click();

		WebElement pfAmount = driver.findElement(By.xpath("//input[@id='pfAmountInput']"));
		pfAmount.clear();
		pfAmount.sendKeys("1000");
		Select pfType = new Select(driver.findElement(By.xpath("//select[@id='pfTypeCode']")));
		pfType.selectByVisibleText("COLLECT");
		driver.findElement(By.xpath("//input[@id='btnAddPf']")).click();
		driver.findElement(By.xpath("//input[@value='Save']")).click();
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		
		driver.findElement(By.xpath("//input[@id='dischargeAction']")).click();
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		
		driver.findElement(By.xpath("//div[@id='dischargeForm']/input[@value='Discharge']")).click();
		System.out.println("Discharged on Nursing Unit");
	}
	
}
